# Contributor: Adrian L Lange <alpine@p3lim.net>
# Contributor: Charles Wimmer <charles@wimmer.net>
# Contributor: Dermot Bradley <dermot_bradley@yahoo.com>
# Maintainer: Dermot Bradley <dermot_bradley@yahoo.com>
pkgname=step-certificates
pkgver=0.21.0
pkgrel=0
pkgdesc="Online certificate authority and related tools"
url="https://smallstep.com/certificates/"
arch="all !s390x !riscv64" # step-cli
license="Apache-2.0"
makedepends="
	bash
	go
	go-bindata
	libcap
	pcsc-lite-dev
	"
depends="step-cli"
options="!check" # No tests as fails for Yubikey
install="$pkgname.pre-install"
subpackages="
	$pkgname-openrc
	"
source="
	$pkgname-$pkgver.tar.gz::https://github.com/smallstep/certificates/releases/download/v$pkgver/step-ca_$pkgver.tar.gz
	01-Makefile-GOFLAGS.patch
	02-Makefile-yubikey-and-pkcs11-binary.patch
	step-ca.confd
	step-ca.initd
	step-ca.logrotate
	"
builddir="$srcdir"

build() {
	make simple
}

check() {
	make test
}

package() {
	make DESTDIR="$pkgdir" install
	setcap cap_net_bind_service=+ep "$pkgdir"/usr/bin/step-ca

	install -m 644 -D "$srcdir"/step-ca.confd "$pkgdir"/etc/conf.d/step-ca
	install -m 755 -D "$srcdir"/step-ca.initd "$pkgdir"/etc/init.d/step-ca

	install -m 644 -D "$srcdir"/step-ca.logrotate "$pkgdir"/etc/logrotate.d/step-ca
}

sha512sums="
aca6762eacf07a2a347201d588d21550ab3b4419e8051d3cd167f0d1c5b20239818fd88ac9260ca2c21e5bb0c0367b63beae2defc234296db69c303d1d0ddb19  step-certificates-0.21.0.tar.gz
fce464b646dfb087da27beed7135c52b2926df8595675ab3117afa9a98ac2c8ac8bed57ddf6567bcccc417dc076321a230a77ef029fad2ab3213c2b3655eb66b  01-Makefile-GOFLAGS.patch
0b49bda9b0b0df9d9e10ab96405a8eff5b50aaf354b8ce424d4f085ef7b033d98169521f798b27dce3959ea18cf97da365613417c40a3d54779fad7ecc15e3d4  02-Makefile-yubikey-and-pkcs11-binary.patch
b207ff9a887389334b624ae5e389379b6ee37bec712dbc075e3c6447f2e542594dbcddc75f0d4b057e1b855fd135a625e6e6c6caff02a9e4de8475318a655836  step-ca.confd
45a82345ad5906f3eef84df5c71d5b830423d51e1e86447937fac7efbbfd78bfcc93e30dab06d4baf8198223f1cb1e8f5551b70385702b976a30f4aebb0b8963  step-ca.initd
17740fbe3a72f1c9fe4f90dffb368ad4fe6b98a36512ca58614a4bfbc4b6895ecc6daa4a5a78abcd9b1840eb63ce90523d7fa77a2b42da0cf539bf36330c9f32  step-ca.logrotate
"
